home *** CD-ROM | disk | FTP | other *** search
Wrap
/xlv1/freeware/1998.Oct/procmail/3.11pre7/procmail-3.11pre7.diffbuild/new LLLLOOOOCCCCKKKKFFFFIIIILLLLEEEE((((1111)))) BBBBuuuuGGGGlllleeeessssssss ((((1111999999997777////00004444////11111111)))) LLLLOOOOCCCCKKKKFFFFIIIILLLLEEEE((((1111)))) NNNNAAAAMMMMEEEE lockfile - conditional semaphore-file creator SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS lllloooocccckkkkffffiiiilllleeee ----_s_l_e_e_p_t_i_m_e | ----rrrr _r_e_t_r_i_e_s | ----llll _l_o_c_k_t_i_m_e_o_u_t | ----ssss _s_u_s_p_e_n_d | ----!!!! | ----mmmmllll | ----mmmmuuuu | _f_i_l_e_n_a_m_e ... DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN lllloooocccckkkkffffiiiilllleeee can be used to create one or more _s_e_m_a_p_h_o_r_e _f_i_l_e_s. If lockfile can't create all the specified files (in the specified order), it waits _s_l_e_e_p_t_i_m_e (defaults to 8) seconds and retries the last file that didn't succeed. You can specify the number of _r_e_t_r_i_e_s to do until failure is returned. If the number of _r_e_t_r_i_e_s is -1 (default, i.e. ----rrrr----1111) lockfile will retry forever. If the number of _r_e_t_r_i_e_s expires before all files have been created, lockfile returns failure and removes all the files it created up till that point. The return value of lockfile can be easily inverted by specifying ----!!!! as an argument (comes in handy in shell scripts). All flags can be specified anywhere on the command line, they will be processed when encountered. The command line is simply parsed from left to right. All files created by lockfile will be read-only, and therefore will have to be removed with rrrrmmmm ----ffff. If you specify a _l_o_c_k_t_i_m_e_o_u_t then a lockfile will be removed by force after locktimeout seconds have passed since the lockfile was last modified/created (most likely by some other program that unexpectedly died a long time ago, and hence could not clean up any leftover lockfiles). Lockfile is clock skew immune. After a lockfile has been removed by force, a suspension of _s_u_s_p_e_n_d seconds (defaults to 16) is taken into account, in order to prevent the inadvertent immediate removal of any newly created lockfile by another program (compare SSSSUUUUSSSSPPPPEEEENNNNDDDD in pppprrrrooooccccmmmmaaaaiiiillll(1)). MMMMaaaaiiiillllbbbbooooxxxx lllloooocccckkkkssss If the permissions on the system mail spool directory allow it, or if lockfile is suitably setgid, it will be able to lock and unlock your system mailbox by using the options ----mmmmllll and ----mmmmuuuu respectively. Page 1 (printed 8/25/98) LLLLOOOOCCCCKKKKFFFFIIIILLLLEEEE((((1111)))) BBBBuuuuGGGGlllleeeessssssss ((((1111999999997777////00004444////11111111)))) LLLLOOOOCCCCKKKKFFFFIIIILLLLEEEE((((1111)))) EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS Suppose you want to make sure that access to the file "important" is serialised, i.e. no more than one program or shell script should be allowed to access it. For simplicity's sake, let's suppose that it is a shell script. In this case you could solve it like this: ... lockfile important.lock ... access_"important"_to_your_hearts_content ... rm -f important.lock ... Now if all the scripts that access "important" follow this guideline, you will be assured that at most one script will be executing between the `lockfile' and the `rm' commands. EEEENNNNVVVVIIIIRRRROOOONNNNMMMMEEEENNNNTTTT LLLLOOOOGGGGNNNNAAAAMMMMEEEE used as a hint to determine the invoker's loginname FFFFIIIILLLLEEEESSSS ////eeeettttcccc////ppppaaaasssssssswwwwdddd to verify and/or correct the invoker's loginname (and to find out his HOME directory, if needed) ////vvvvaaaarrrr////mmmmaaaaiiiillll////$$$$LLLLOOOOGGGGNNNNAAAAMMMMEEEE....lllloooocccckkkk lockfile for the system mailbox, the environment variables present in here will not be taken from the environment, but will be determined by looking in /etc/passwd SSSSEEEEEEEE AAAALLLLSSSSOOOO rrrrmmmm(1), mmmmaaaaiiiillll(1), bbbbiiiinnnnmmmmaaaaiiiillll(1), sssseeeennnnddddmmmmaaaaiiiillll(8), pppprrrrooooccccmmmmaaaaiiiillll(1) DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS Filename too long, ... Use shorter filenames. Forced unlock denied on "x" No write permission in the directory where lockfile "x" resides, or more than one lockfile trying to force a lock at exactly the same time. Page 2 (printed 8/25/98) LLLLOOOOCCCCKKKKFFFFIIIILLLLEEEE((((1111)))) BBBBuuuuGGGGlllleeeessssssss ((((1111999999997777////00004444////11111111)))) LLLLOOOOCCCCKKKKFFFFIIIILLLLEEEE((((1111)))) Forcing lock on "x" Lockfile "x" is going to be removed by force because of a timeout (com- pare LLLLOOOOCCCCKKKKTTTTIIIIMMMMEEEEOOOOUUUUTTTT in pppprrrrooooccccmmmmaaaaiiiillll(1)). Out of memory, ... The system is out of swap space. Signal received, ... Lockfile will remove anything it created till now and terminate. Sorry, ... The _r_e_t_r_i_e_s limit has been reached. Truncating "x" and retrying lock "x" does not seem to be a valid filename. Try praying, ... Missing subdirectories or insuffi- cient privileges. BBBBUUUUGGGGSSSS Definitely less than one. MMMMIIIISSSSCCCCEEEELLLLLLLLAAAANNNNEEEEOOOOUUUUSSSS Lockfile is NFS-resistant and eight-bit clean. NNNNOOOOTTTTEEEESSSS Calling up lockfile with the -h or -? options will cause it to display a command-line help page. Multiple ----!!!! flags will toggle the return status. Since flags can occur anywhere on the command line, any filename starting with a '-' has to be preceded by './'. The number of _r_e_t_r_i_e_s will not be reset when any following file is being created (i.e. they are simply used up). It can, however, be reset by specifying -r_n_e_w_r_e_t_r_i_e_s after every file on the command line. Although files with any name can be used as lockfiles, it is common practice to use the extension `.lock' to lock mail- folders (it is appended to the mailfolder name). In case one does not want to have to worry about too long filenames and does not have to conform to any other lockfilename con- vention, then an excellent way to generate a lockfilename corresponding to some already existing file is by taking the prefix `lock.' and appending the i-node number of the file which is to be locked. SSSSOOOOUUUURRRRCCCCEEEE This program is part of the _p_r_o_c_m_a_i_l _m_a_i_l-_p_r_o_c_e_s_s_i_n_g-_p_a_c_k_a_g_e (v3.11pre7 1997/04/28) available at your nearest USENET comp.sources.misc archive, or at ftp.informatik.rwth- Page 3 (printed 8/25/98) LLLLOOOOCCCCKKKKFFFFIIIILLLLEEEE((((1111)))) BBBBuuuuGGGGlllleeeessssssss ((((1111999999997777////00004444////11111111)))) LLLLOOOOCCCCKKKKFFFFIIIILLLLEEEE((((1111)))) aachen.de as ppppuuuubbbb////ppppaaaacccckkkkaaaaggggeeeessss////pppprrrrooooccccmmmmaaaaiiiillll////pppprrrrooooccccmmmmaaaaiiiillll....ttttaaaarrrr....ggggzzzz. MMMMAAAAIIIILLLLIIIINNNNGGGGLLLLIIIISSSSTTTT There exists a mailinglist for questions relating to any program in the procmail package: <procmail@informatik.rwth-aachen.de> for submitting questions/answers. <procmail-request@informatik.rwth-aachen.de> for subscription requests. If you would like to stay informed about new versions and official patches send a subscription request to procmail-announce-request@informatik.rwth-aachen.de (this is a readonly list). AAAAUUUUTTTTHHHHOOOORRRR Stephen R. van den Berg <srb@cuci.nl> Page 4 (printed 8/25/98)